#ifndef _PROFILEDIALOG_H
#define _PROFILEDIALOG_H

#include <amanita/aVector.h>
#include "Profile.h"
#include "astro/Horoscope.h"



class ProfileDlg {
private:
	struct category {
		int index;
		char code[5];
		char name[64];
		int lvl;
		category *child,*parent;
	};

	size_t ncats,ncountries,ntimezones,timezonesgmtindex;
	category *cats;
	char *countries,*timezones,longitude[9],latitude[9];
	float *tzgmt;
	uint64_t profileid;

	struct {
		GtkWidget *window;
		GtkWidget *name;
		GtkWidget *year;
		GtkWidget *month;
		GtkWidget *day;
		GtkWidget *hour;
		GtkWidget *minute;
		GtkWidget *second;
		GtkWidget *country;
		GtkWidget *location;
		GtkWidget *location2;
		GtkWidget *longitude;
		GtkWidget *latitude;
		GtkWidget *timezone;
		GtkWidget *dst;
		GtkWidget *catlist;
		GtkWidget *profilelist;
	} gtk;

	static gboolean delete_event_callback(GtkWidget *widget,GtkWidget *event,gpointer data);
	static void catlist_selection_changed_callback(GtkWidget *widget,gpointer data);
	static void profilelist_selection_changed_callback(GtkWidget *widget,gpointer data);
	static void ok_clicked_callback(GtkWidget *widget,gpointer data);
	static void save_clicked_callback(GtkWidget *widget,gpointer data);
	static void savenew_clicked_callback(GtkWidget *widget,gpointer data);
	static void cancel_clicked_callback(GtkWidget *widget,gpointer data);
	static void clear_clicked_callback(GtkWidget *widget,gpointer data);
	static void delete_clicked_callback(GtkWidget *widget,gpointer data);

	//void (*eventFunction)(void *o,Profile *p);

	void loadCategories();
	/*void selectCountry(const char *code);
	void printCountry(char *str,const char *code,const char *name);
	void getCountryCode(char *code,const char *str);
	void printTimeZone(char *str,float gmt,const char *name);
	float getTimeZone(const char *str,char *tz);
	void setProfile(Profile &p);
	void getProfile(Profile &p);*/

public:
	ProfileDlg(GtkWindow *parent);
	~ProfileDlg();

	void createNatalHoroscope(Profile *p=0);
	/*void createRelationHoroscope(int n1,int n2,int st);
	void setHoroscopeStyle(int st);*/

	void show();
	void hide();

	void setCategory(const char *code=0);
	category *getCategory();
	void loadProfiles(category *c=0);
	void loadProfile(uint64_t id);
	void setProfile(Profile &p);
	void getProfile(Profile &p);

	void openBirthChart(uint64_t id);
	void clearForm();
	void saveProfile(uint64_t id);
	void deleteProfile(uint64_t id);
	void readCoordinate(char *d,const char *s);
};


#endif /* _PROFILEDIALOG_H */

